package script.functions

import com.tang.script.functions.ScriptFunction


@ScriptFunction(functionName = "是否为空")
static boolean isEmpty(obj) {
    if (Objects.isNull(obj)) return true
    if (obj instanceof Collection) {
        Collection collect = obj
        if (collect.isEmpty()) {
            return true
        }
        def res = new LinkedList<>()
        for (final def item in collect) {
            res.add(doIsEmpty(item))
        }
        return res
    }
    return doIsEmpty(obj)
}

static def boolean doIsEmpty(Object o) {
    if (Objects.isNull(o) || "".equals(o)) return true
    return false
}
